<template>
  <div class="Login">
    <van-nav-bar
      title="Topsales信息维护"
      left-text="返回"
      left-arrow
      @click-left="onClickLeft"
      @click-right="onClickRight"
    />
    <van-tabs>
      <van-tab title="手机登录">
        <van-form>
          <van-field placeholder="请输入手机号" :rules="[{ required: true, message: '请填写手机号' }]" />
          <van-field
            type="password"
            placeholder="请输入验证码"
            :rules="[{ required: true, message: '请填写验证码' }]"
          />
        </van-form>
        <van-button type="primary" block @click="Login">登录1</van-button>
      </van-tab>
      <van-tab title="账号登录">
        <van-form>
          <van-field
            v-model="form.number"
            placeholder="请输入账号"
            :rules="[{ required: true, message: '请填写账号' }]"
          />
          <van-field
            v-model="form.password"
            type="password"
            placeholder="请输入密码"
            :rules="[{ required: true, message: '请填写密码' }]"
          />
        </van-form>
        <van-button type="primary" block @click="Login">登录</van-button>
      </van-tab>
    </van-tabs>
  </div>
</template>

<script>
// import { login } from '@/api/login'
export default {
  name: 'login',
  data() {
    return {
      value: '',
      form: {
        number: '你好',
        password: '1111'
      },
      hostName: 'http://ruiyinwx.free.idcfengye.com',
      wxAppId: 'wxab8557c5d0a4bb46'
    }
  },
  created() {
    let str = window.location.href
    console.log('str', str)
    this.code = this.$route.query.code
    console.log('code值>>>>'+ this.code)
  },

  methods: {
    onClickLeft() {},
    onClickRight() {},
    Login() {
      let url = this.hostName + '/wxAuth/callBack/'
      let redirectUrl = encodeURIComponent(url)  //encode编码
      let str =
        'https://open.weixin.qq.com/connect/oauth2/authorize?appid=' +
        this.wxAppId
        + '&redirect_uri='
        + redirectUrl
        + '&response_type=code&scope=snsapi_userinfo&state=STATE#wechat_redirect#wechat_redirect'
      console.log('微信授权连接：', str)
      window.location.href = str
      console.log(this.code)
    },
  }
}
</script>

<style lang="scss" scoped>
/deep/ .van-nav-bar {
  height: 45px;
}
/deep/ #app {
  margin-top: 0;
}
/deep/ .van-nav-bar .van-icon {
  color: #333;
}
/deep/ .van-nav-bar__text {
  color: #333;
}
/deep/.van-tabs__content {
  margin: 0.5rem 0.8rem 0 0.8rem;
  margin-top: 0.5rem;
}
/deep/.van-tabs__line {
  height: 2px;
  background-color: #0c1b35;
  width: 50px !important;
}
/deep/.van-tab__text--ellipsis {
  margin-top: 13px;
}
/deep/ .van-cell {
  line-height: 40px;
}
/deep/.van-cell-group {
  margin-top: 25px;
}
/deep/.van-button--primary {
  color: #fff;
  background-color: #0c1b35;
  border: 0.02667rem solid #0c1b35;
  margin-top: 40px;
  border-radius: 4px;
  height: 40px;
}
/deep/ [class*='van-hairline']::after {
  border-top: 0;
}
</style>
